package com.LFLWZ.serivceImpl;

import com.LFLWZ.beans.POJO.Comments;
import com.LFLWZ.beans.Vo.CommentsByReplyVo;
import com.LFLWZ.beans.Vo.CommentsVo;
import com.LFLWZ.mapper.CommentsMapper;
import com.LFLWZ.service.CommentsService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 评论表(Comments)表服务实现类
 *
 * @author lujum
 * @since 2020-12-25 02:08:27
 */
@Service
public class CommentsServiceImpl implements CommentsService {

    @Autowired
    private CommentsMapper CommentsMapper;


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Comments queryById(Integer id) {
        return this.CommentsMapper.queryById(id);
    }

    @Override
    public int deleteByAid(Integer aid) {
        return CommentsMapper.deleteByAid(aid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Comments> queryAllByLimit(int offset, int limit) {
        return this.CommentsMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param comments 实例对象
     * @return 实例对象
     */
    @Override
    public Comments insert(Comments comments) {
        this.CommentsMapper.insert(comments);
        return comments;
    }

    /**
     * 修改数据
     *
     * @param comments 实例对象
     * @return 实例对象
     */
    @Override
    public Comments update(Comments comments) {
        this.CommentsMapper.update(comments);
        return this.queryById(comments.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.CommentsMapper.deleteById(id) > 0;
    }

    @Override
    public List<CommentsByReplyVo> queryAll(Comments comments) {
        return CommentsMapper.queryAll2(comments);
    }

    @Override
    public List<Comments> selReply(Comments comments) {
        return CommentsMapper.selReply(comments);
    }
}